<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.prime.com.tr/ui">

    <body>

        <ui:composition template="./template.xhtml">

            <ui:define name="title">
                Báo cáo xử lý yêu cầu khách hàng
            </ui:define>

            <ui:define name="content">
                <h:form>
                    <h:panelGrid columns="2">
                        <p:panel header="Tìm kiếm">
                            <h:panelGrid columns="2">
                                Số thuê bao
                                <p:inputText value="#{requestQueueHistBean.selectedMsisdn}"/>

                                Thời gian <h:outputText/>
                                Từ
                                <p:calendar value="#{requestQueueHistBean.startDate}" pattern="dd/MM/yyyy HH:mm:ss" timeZone="Asia/Saigon" navigator="true"/>
                                Đến 
                                <p:calendar value="#{requestQueueHistBean.endDate}" pattern="dd/MM/yyyy HH:mm:ss" timeZone="Asia/Saigon" navigator="true"/>

                                <p:commandButton ajax="false" value="Tìm MO" action="#{requestQueueHistBean.searchMo()}"/>
                                <p:commandButton ajax="false" value="Tìm MT" action="#{requestQueueHistBean.searchMt()}"/>
                            </h:panelGrid>
                        </p:panel>

                    </h:panelGrid>
                </h:form>

                <br/>
                
                <h:form>
                    <p:commandButton ajax="false" value="Xuất ra Excel"  rendered="#{requestQueueHistBean.list != null}">
                        <p:dataExporter target="requestTable" type="xls" fileName="baocao"/>
                    </p:commandButton>
                    <p:dataTable id="requestTable" value="#{requestQueueHistBean.list}" var="item" paginator="#{requestQueueHistBean.list.size()>20}" rows="20" 
                                 resizableColumns="true" rendered="#{requestQueueHistBean.list != null}">
                        <p:column headerText="Số gửi đến" sortBy="#{item.msisdn}">
                            <h:outputText value="#{item.msisdn}"/>
                        </p:column>
                        <p:column headerText="Nội dung" sortBy="#{item.requestDetail}" >
                            <h:outputText value="#{item.requestDetail}"/>
                        </p:column>
                        <p:column headerText="ND cũ" sortBy="#{item.oldContent}" >
                            <h:outputText value="#{item.oldContent}"/>
                        </p:column>
                        <p:column headerText="Giờ nhận" sortBy="#{item.receivedTime}">
                            <h:outputText value="#{item.receivedTime}">
                                <f:convertDateTime pattern="dd/MM/yyyy HH:mm:ss" timeZone="Asia/Saigon"/>
                            </h:outputText>
                        </p:column>
                        <p:column headerText="Đầu số" sortBy="#{item.cpNumber}">
                            <h:outputText value="#{item.cpNumber}"/>
                        </p:column>
                        <p:column headerText="Dịch vụ" sortBy="#{item.serviceName}">
                            <h:outputText value="#{item.serviceName}"/>
                        </p:column>
                        <p:column headerText="Trạng thái" sortBy="#{item.status}">
                            <h:outputText value="#{item.status}"/>
                        </p:column>
                        <p:column headerText="Nội dung trả về" sortBy="#{item.responseContent}">
                            <h:outputText value="#{item.responseContent}"/>
                        </p:column>
                        <p:column headerText="Giờ kiểm tra cuối" sortBy="#{item.lastCheckTime}">
                            <h:outputText value="#{item.lastCheckTime}">
                                <f:convertDateTime pattern="dd/MM/yyyy HH:mm:ss" timeZone="Asia/Saigon"/>
                            </h:outputText>
                        </p:column>
                    </p:dataTable>
                    <p:commandButton ajax="false" value="Xuất ra Excel" rendered="#{requestQueueHistBean.list != null}">
                        <p:dataExporter target="requestTable" type="xls" fileName="baocao"/>
                    </p:commandButton>
                </h:form>

            </ui:define>

        </ui:composition>

    </body>
</html>
